import { Pipe, PipeTransform } from "@angular/core";
import { DomSanitizer } from '@angular/platform-browser';
 
@Pipe({ name: 'keyMap' })
export class KeyMapPipe implements PipeTransform {
  constructor(private sanitizer: DomSanitizer) {}
  transform(value, key: string) {
    switch (key) {
      case 'RightOrNot':
        return value === 0 ? RightOrNot.not : RightOrNot.right
      case 'Sex':
        return value === 0 ? Sex.female : Sex.man
      case 'Publish':
        return value === 0 ? Publish.unpublished : Publish.published
      default:
        break;
    }
  }
}

enum RightOrNot {
  right = '是',
  not = '否'
}

enum Sex {
  man = '男',
  female = '女'
}

enum Publish {
  published = '已发布',
  unpublished = '未发布'
}